package leetcode;

import javax.xml.crypto.Data;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by MtRider on 2021/10/31 15:39
 */
public class DayOfWeak {
    public static void main(String[] args) {
        System.out.println(dayOfTheWeek(30, 10, 2021));
    }

    public static String dayOfTheWeek(int day, int month, int year) {
        Calendar calendar = Calendar.getInstance();
        String data = year + "-" + month + "-" + day;
        DateFormat fmtDateTime = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = null;
        try {
            parse = fmtDateTime.parse(data);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        calendar.setTime(parse);
        int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
        String dayName = "";
        //{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
        ////"Friday", "Saturday"}。
        switch (weekDay) {
            case 1:
                dayName = "Sunday";
                break;
            case 2:
                dayName = "Monday";
                break;
            case 3:
                dayName = "Tuesday";
                break;
            case 4:
                dayName = "Wednesday";
                break;
            case 5:
                dayName = "Thursday";
                break;
            case 6:
                dayName = "Friday";
                break;
            case 7:
                dayName = "Saturday";
                break;
            default:
                break;
        }
        return dayName;
    }
}
